package com.victor.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.victor.controller.AdvertisementController;
import com.victor.dao.AdvertisementDao;
import com.victor.entity.Advertisement;
import com.victor.service.AdvertisementService;

@Service
public class AdvertisementServiceImpl implements AdvertisementService {
	@Autowired
	private AdvertisementDao advertisementDao;

	@Override
	public boolean insert(Advertisement advertisement) {
		return advertisementDao.insertSelective(advertisement);
	}

	@Override
	public boolean update(Advertisement advertisement) {
		return advertisementDao.updateByPrimaryKeySelective(advertisement);
	}

	@Override
	public PageInfo<Advertisement> getAll(int page, int row) {
		PageHelper.startPage(page, row);
		List<Advertisement> list = advertisementDao.selectAll();
		return new PageInfo<>(list, 5);
	}

	@Override
	public Advertisement selById(Advertisement advertisement) {
		return advertisementDao.selectByPrimaryKey(advertisement);
	}

	@Override
	public boolean delete(int[] ids) {
		return advertisementDao.deleteByPrimaryKey(ids);
	}

}
